﻿using Hr.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hr.Model;

namespace Hr.BLL
{
    public class DashboardService
    {
        private DashboardDAL dal = new DashboardDAL();

        /// <summary>
        /// 控制面板获取所有相关信息
        /// </summary>
        /// <param name="pk_User"></param>
        /// <returns></returns>
        public Dictionary<string,object> GetDashboardInfo(int pk_User)
        {
            return dal.GetDashboardInfo(pk_User);
        }

        #region 便签操作

        /// <summary>
        /// 根据便签ID，获取便签信息
        /// </summary>
        /// <param name="pk_Memo"></param>
        /// <returns></returns>
        public Memo_List GetMemoInfo(int pk_Memo)
        {
            return dal.GetMemoInfo(pk_Memo);
        }

        /// <summary>
        /// 获取便签信息，模糊查寻，分页
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="Term"></param>
        /// <returns></returns>
        public Dictionary<string,object> GetMemoList(int pk_User,int page,int limit,string Term)
        {
            Dictionary<string, object> dt = new Dictionary<string, object>()
            {
                {"MemoList",dal.GetMemoList(pk_User,Term).Skip(limit * (page - 1)).Take(limit).ToList() },
                {"Count", dal.GetMemoList(pk_User,Term).Count()}
            };
            return dt;
        }

        /// <summary>
        /// 添加、修改便签内容
        /// </summary>
        /// <param name="M"></param>
        /// <param name="Type"></param>
        /// <param name="pk_User"></param>
        /// <returns></returns>
        public bool UpdateMemo(Memo_List M,string Type,int pk_User)
        {
            dal.UpdateMemo(M, Type, pk_User);
            return dal.SaveChanges();
        }


        /// <summary>
        /// 删除便签
        /// </summary>
        /// <param name="M"></param>
        /// <returns></returns>
        public bool DelMemo(Memo_List M)
        {
            dal.DelMemo(M);
            return dal.SaveChanges();
        }

        #endregion

        #region 个人设置操作

        /// <summary>
        /// 根据ID获取用户信息
        /// </summary>
        /// <param name="pk_User"></param>
        /// <returns></returns>
        public User_List GetUserListInfo(int pk_User)
        {
            return dal.GetUserListInfo(pk_User);
        }


        /// <summary>
        /// 修改用户头像
        /// </summary>
        /// <param name="pk_User"></param>
        /// <param name="URL"></param>
        /// <returns></returns>
        public bool UpdateImg(int pk_User,string URL)
        {
            dal.UpdateImg(pk_User, URL);
            return dal.SaveChanges();
        }

        /// <summary>
        /// 个人中心修改用户信息
        /// </summary>
        /// <param name="U"></param>
        /// <param name="pk_User"></param>
        /// <returns></returns>
        public bool UpdateUserInfo(User_List U,int pk_User)
        {
            dal.UpdateUserInfo(U, pk_User);
            return dal.SaveChanges();
        }
        #endregion
    }
}
